extends AudioStreamPlayer

enum Music {NONE, MENU, GAMEPLAY, TOURNAMENT, WIN}

const MUSIC_MAP : Dictionary[Music, AudioStream] = {
	Music.GAMEPLAY: preload("uid://diptxevhb103y"),
	Music.MENU: preload("uid://bttlsex5uys3v"),
	Music.TOURNAMENT: preload("uid://beuh5bd6awhfc"),
	Music.WIN: preload("uid://1pkja84q3ade")
}

var current_music: Music = Music.NONE

func _ready() -> void:
	process_mode = Node.PROCESS_MODE_ALWAYS
	
func play_music(new_music: Music) -> void:
	if new_music != current_music and MUSIC_MAP.has(new_music):
		current_music = new_music
		stream = MUSIC_MAP.get(new_music)
		play()
